package com.yangquan.ayuan.unsafe;

public class UnSafeApp {
    public static void main(String[] args) throws InterruptedException {
        MyAtomicInteger counter = new MyAtomicInteger(0);

        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                counter.increment();
            }
        });

        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                counter.increment();
            }
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();

        System.out.println("最终计数值：" + counter.get());
    }
}